<?php

namespace api\goods\controller;

class AdminIndexController extends \Aaa\goods\controller\AdminIndexController {

    protected $baseField = [
        [
            'field' => 'id',
            'name' => 'ID',
        ],
        [
            'field' => 'user_id',
            'name' => '用户ID',
            'view' => [
                'route' => 'user/AdminUser/view',
            ],
        ],
        [
            'field' => 'status',
            'name' => '上架状态',
            'type' => 'radio',
            'options' => [
                ['name' => '已下架', 'value' => 0],
                ['name' => '审核中', 'value' => 1],
                ['name' => '审核失败', 'value' => 2],
                ['name' => '已上架', 'value' => 3],
            ],
        ],
        [
            'field' => 'review_reason',
            'name' => '审核原因',
        ],
        [
            'field' => 'game_id_level_1',
            'name' => '游戏分类',
            'type' => 'select',
            'optionsSource' => [
                'table' => 'game',
                'nameField' => 'name',
                'valueField' => 'id',
                'where' => [['level', '=', 1]],
            ],
        ],
        [
            'field' => 'game_server',
            'name' => '游戏区服',
        ],
        [
            'field' => 'type_name',
            'name' => '商品类型',
        ],
        [
            'field' => 'delivery_type',
            'name' => '发货类型',
            'type' => 'radio',
            'options' => [
                ['name' => '卖家发货', 'value' => 0],
                ['name' => '平台代发', 'value' => 1],
            ],
        ],
        [
            'field' => 'compensation_id',
            'name' => '包赔服务',
            'type' => 'select',
            'options' => [
                ['name' => '无', 'value' => 0],
            ],
            'optionsSource' => [
                'table' => 'goods_compensation',
                'nameField' => 'name',
                'valueField' => 'id',
            ],
        ],
        [
            'field' => 'create_time',
            'name' => '发布时间',
            'type' => 'time',
        ],
        [
            'field' => 'title',
            'name' => '商品名称',
        ],
        [
            'field' => 'bright_spot',
            'name' => '商品亮点',
        ],
        [
            'field' => 'price',
            'name' => '商品价格',
        ],
        [
            'field' => 'quantity',
            'name' => '商品数量',
        ],
        [
            'field' => 'quantity_sold',
            'name' => '已出售商品数量',
        ],
        [
            'field' => 'inventory_quantity',
            'name' => '剩余商品数量',
        ],
        [
            'field' => 'description',
            'name' => '商品描述',
            'type' => 'textarea',
        ],
        [
            'field' => 'image',
            'name' => '商品图片',
            'type' => 'images',
            'limit' => 30,
        ],
        [
            'field' => 'expiration_time',
            'name' => '商品有效期',
        ],
        [
            'field' => 'transaction_code',
            'name' => '交易码',
        ],
        [
            'field' => 'mobile',
            'name' => '联系手机',
        ],
        [
            'field' => 'qq',
            'name' => '联系QQ',
        ],
        [
            'field' => 'wechat',
            'name' => '联系微信',
        ],
        [
            'field' => 'referral_code',
            'name' => '推荐码',
        ],
    ];

    protected function beforeIndex() {
        $this->actionField = [
            'id',
            'user_id',
            'create_time',
            'status',
            'review_reason',
            'game_id_level_1',
            'game_server',
            'type_name',
            'delivery_type',
            'compensation_id',
            'title',
            'price',
            'quantity',
            'mobile',
            'qq',
            'wechat',
            'referral_code',
        ];
        $this->searchField = [
            'common' => [
                'id' => 'accurate',
                'title' => 'fuzzy',
                'status' => 'accurate',
                'review_reason' => 'fuzzy',
                'delivery_type' => 'accurate',
                'compensation_id' => 'accurate',
                'game_id_level_1' => 'accurate',
                'game_server' => 'fuzzy',
                'mobile' => 'fuzzy',
                'qq' => 'fuzzy',
                'wechat' => 'fuzzy',
                'referral_code' => 'accurate',
            ],
            'amount' => ['price', 'quantity', 'create_time',]
        ];
    }

    protected function beforeReview() {
        $this->beforeIndex();
    }

    protected function beforeEdit() {
        $this->actionField = [
            'status',
            'review_reason',
            'create_time',
            'compensation_id',
            'title',
            'price',
            'quantity',
            'quantity_sold',
            'inventory_quantity',
            'image',
            'transaction_code',
            'mobile',
            'qq',
            'wechat',
            'referral_code',
        ];
    }


}
